package cn.faifai.desktop.config;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;

public class MainStage {
    private static Stage beginStage;

    static public Stage getBeginStage() throws IOException {
        if (beginStage == null) {
            beginStage = getMainStage(new Stage());
        }
        return beginStage;
    }
    static public Stage getMainStage(Stage stage) throws IOException {
        beginStage = stage;
        URL url = MainStage.class.getResource("/FXML/hello-view.fxml");
        if (url == null) throw new RuntimeException("找不到hello-view.fxml");
        FXMLLoader fxmlLoader = new FXMLLoader(url);
        Scene scene = new Scene(fxmlLoader.load(), 320, 240);
        beginStage.setTitle("Hello!");
        beginStage.setScene(scene);
        return beginStage;
    }
}
